package top.sjydzq.one.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import top.sjydzq.one.Mapper.ArticleMapper;
import top.sjydzq.one.Mapper.CommentMapper;

@Controller
public class ArticleController {
    @Autowired
    private ArticleMapper articleMapper;
    @Autowired
    private CommentMapper commentMapper;

    @RequestMapping("/article")
    public String article(Model model, int id) {
        model.addAttribute("article", articleMapper.selectById(id));
        model.addAttribute("comments", commentMapper.selectAllByArticleId(id));

        return "article";
    }
}
